<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-28 13:56:04
 * @LastEditTime: 2019-08-29 09:22:46
 * @LastEditors: Please set LastEditors
 -->
<script>
	// 初始化 echarts 
	var demoChart = echarts.init(document.getElementById('realTimeInvoke'), 'macarons');
	demoChart.setOption({
		// title: {
		// 	text: '柱状图',
		// 	x: 'center',
		// 	y: 'top',
		// 	textAlign: 'center'
		// },
		tooltip: {
			trigger: 'item',
			formatter: '{a} <br/>{b} : {c}'
		},
	});
	demoChart.showLoading();

	//每秒执行定时器
	setInterval(function () {
		var axisval = document.getElementsByName("tx_echarts_pi1[datas][axis][]");
		var seriesval = document.getElementsByName("tx_echarts_pi1[datas][series][]");
		if (axisval.length > 0 && seriesval.length > 0) {
			var axisdata = [];    //类别数组（实际用来盛放X轴坐标值）
			var seriesdata = [];    //销量数组（实际用来盛放Y坐标值）
			for (var i = 0; i < axisval.length; i++) {
				axisdata.push(axisval[i].value);
			}
			for (var j = 0; j < seriesval.length; j++) {
				seriesdata.push(seriesval[j].value);
			}
			demoChart.hideLoading();    //隐藏加载动画
			demoChart.setOption({        //加载数据图表
				xAxis: {
					type: 'category',
					data: axisdata
				},
				yAxis: {
					type: 'value'
				},
				series: [{
					name: '预览',
					type: 'line',
					data: seriesdata
				}]
			});
		}
	}, 1000);

</script>